package com.zuijin.demo.interceptor;

import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.ResultHandler;

import java.sql.Statement;

/**
 * <p>
 *
 * </p>
 *
 * @author DONG.WANG17@HAND-CHINA.COM
 * @apiNote
 * @since 2025-01-15 17:47
 */
@Intercepts({
        @Signature(type= StatementHandler.class,method = "parameterize", args = {Statement.class}),
        @Signature(type= StatementHandler.class,method = "batch", args = {Statement.class}),
        @Signature(type= StatementHandler.class,method = "update", args = {Statement.class}),
        @Signature(type= StatementHandler.class,method = "query", args = {Statement.class, ResultHandler.class}),
        @Signature(type= StatementHandler.class,method = "queryCursor", args = {Statement.class})
})
public class MyStatementHandlerInterceptor implements Interceptor {
    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        System.out.println("MyStatementHandlerInterceptor");
        System.out.println(invocation.getMethod().getName());
        return invocation.proceed();
    }
}
